import { createSlice } from '@reduxjs/toolkit'

const todoSlice = createSlice({
    name: 'todo',
    initialState: {
        list: [
            "1111",
            "2222",
            "3333"
        ]
    },
    reducers: {
        addTodo: (state, { payload }) => {
            state.list.push(payload)
        },
        deleteTodo: (state, { payload }) => {
            state.list = state.list.filter(item => item !== payload)
        }
    }
})

export default todoSlice.reducer
// 导出action 并且action 的名字和reducer 的名字一致
export const { addTodo, deleteTodo } = todoSlice.actions
